//
//  RCTabBarController.m
//  RC-VVeiboOC
//
//  Created by 任淳 on 16/4/2.
//  Copyright © 2016年 ReverChun. All rights reserved.
//

#import "RCTabBarController.h"
#import "HomeViewController.h"
#import "MessageViewController.h"
#import "DiscoveryViewController.h"
#import "MessageViewController.h"
#import "RCTabBar.h"

@interface RCTabBarController ()

@end

@implementation RCTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    RCTabBar *rcTabBar = [[RCTabBar alloc] init];
    
    [self setValue:rcTabBar forKey:@"tabBar"];
    
    //添加子控制器
    [self creatChildControllers];
}

- (void)creatChildControllers {
    
    HomeViewController *homeVC = [[HomeViewController alloc] init];
    MessageViewController *messageVC = [[MessageViewController alloc] init];
    DiscoveryViewController *DiscoveryVC = [[DiscoveryViewController alloc] init];
    MessageViewController * MeVC = [[MessageViewController alloc] init];
    
    [self addChildControllerWithVC:homeVC title:@"首页" imageName:@"tabbar_home"];
    [self addChildControllerWithVC:messageVC title:@"消息" imageName:@"tabbar_message_center"];
    [self addChildControllerWithVC:DiscoveryVC title:@"发现" imageName:@"tabbar_discover"];
    [self addChildControllerWithVC:MeVC title:@"我" imageName:@"tabbar_profile"];
}

- (void)addChildControllerWithVC:(UIViewController *)VC title:(NSString *)title imageName:(NSString *)name {
    
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:VC];
    
    VC.title = title;
    VC.tabBarItem.title = title;
    VC.tabBarItem.image = [UIImage imageNamed:name];
    VC.tabBarItem.selectedImage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_selected",name]];
    
    [self addChildViewController:nav];
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}


@end
